﻿using Microsoft.Practices.Unity;
using SergeyPravodelov.Practice.BookStore.Data.Services;

namespace SergeyPravodelov.Practice.BookStore.Data.Contexts
{
    public class InMemoryDataContext : IContext
    {
        private readonly UnityContainer _injectionContainer;
        public InMemoryDataContext()
        {
            _injectionContainer = new UnityContainer();
            _injectionContainer.RegisterInstance<IDataService>(new InMemoryDataService());
        }

        public TService Get<TService>()
        {
            return _injectionContainer.Resolve<TService>();
        }
    }
}
